// author: shelman
// description：封装了网路通信（TCP和UDP）工具基类的接口
#pragma once


#include <iostream>
#include <functional>
#include <memory>
#include <string>
#include <mutex>
#include <stdint.h>

#include "asio.hpp"
#include "networkutil_common_def.h"


namespace NetworkUtil {


class NetworkUtil_DllExport BaseConnection
{
public:
    BaseConnection() {}
    BaseConnection(const ConnectionConfigInfo& stConnCfgInfo);
    virtual ~BaseConnection();

    void setConnCfgInfo(const ConnectionConfigInfo& stConnCfgInfo);

    virtual void init() = 0;
    virtual void deinit() = 0;

    std::string remoteInfo(const asio::ip::udp::endpoint& objEndPoint);
    std::string remoteInfo(const asio::ip::tcp::endpoint& objEndPoint);

protected:
    volatile bool m_bInited = false;
    volatile bool m_bRunning = false;
    ConnectionConfigInfo m_stConnCfgInfo;
    std::shared_ptr<asio::io_context> m_sp4ObjIOCtx = nullptr;
};


} // namespace NetworkUtil

